﻿using System;
using System.Collections.Generic;
using System.Text;
using Konstaller;

namespace TestApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            
            Console.BackgroundColor = ConsoleColor.Blue;
            ConsoleKeyInfo k = new ConsoleKeyInfo();
            int w = 100;
            int h = 40;

            bool dialog_mostrato = false;

            #region old
            /*
            
            start:


            //Inizializzo la finestra
            Window win = new Window();
            win.initialize(w, h);

            /*
            //Esempio Main Menu
            MainMenu mn = new MainMenu();
            MainMenu.menuitem mni = new MainMenu.menuitem();
            mn.Initalize(w, h);
            mni.Name = "File";
            mni.Text = "FILE";
            mni.id = 0;

            mn.AddMenu(mni);
            mn.DrawMenu();*/


            /*


            // Esempio Progress Bar
            ProgressBar p = new ProgressBar();
            p.Text = "Progresso:";
            p.Value = 8;
            p.Draw(10, 10);

         
            //Esempio Label
            Label lb = new Label();
            lb.Text = "Premi e tieni premuto enter per Incrementare la progress bar";
            lb.Draw(10, 8, ConsoleColor.Yellow);



            //Esempio TextBox
            Label lb2 = new Label();
            lb2.Text = "TextBoxt";
            lb2.Draw(10, 20, ConsoleColor.Yellow);

            TextBox tx = new TextBox();
            tx.Draw(20, 20);


            //Esempio CheckBox

            CheckBox ck = new CheckBox();
            ck.Checked = true;
            ck.Text = "CheckBox";
            ck.Draw(20, 30);


            //Panel pp = new Panel();
            //pp.Draw(60, 15);


            Console.ReadKey();


            if (!dialog_mostrato)
            {
                Dialog dlg = new Dialog();
                dlg.Show("Dialog Esempio. Premi Invio per continuare...");

                k = Console.ReadKey();

                if (k.Key == ConsoleKey.Enter)
                {
                    dialog_mostrato = true;
                    Console.Clear();
                    goto start;
                }
            }


            render:

            //Premi Enter per incrementare la Progress Bar
            
            k = Console.ReadKey();

            if (k.Key == ConsoleKey.Enter)
            {
                p.Value++;
                p.Draw(10, 10);
            }

            goto render;


            */

            #endregion


            Initialize:

          //Initialize
            Window win = new Window();
            win.initialize(w, h);


          


            //You can put this code in or out cicle
            //But is nice out cile
            //In render cicle write other code, type function and if the control need to change value type ProgressBar
            Label lb = new Label();
            lb.Text = "Welcome on Konstaller Example Application";
            lb.Draw(2, 5, ConsoleColor.Yellow,ConsoleColor.Blue);

            Label lb2 = new Label();
            lb.Text = "More Label text...";
            lb.Draw(2, 6, ConsoleColor.Yellow, ConsoleColor.Blue);


            //Progressbar Example

            Label lb3 = new Label();
            lb3.Text = "This is a simple ProgressBar";
            lb3.Draw(2, 8, ConsoleColor.Yellow, ConsoleColor.Blue);

            ProgressBar p = new ProgressBar();
            p.Text = "Simple ProgressBar";
            p.Value = 10;
            p.Draw(2, 12);

            Label lb5 = new Label();
            lb5.Text = "Press Enter to increment";
            lb5.Draw(40, 12, ConsoleColor.Red, ConsoleColor.Blue);
            //Look render cicle


            //TextBox Example
            Label lb4 = new Label();
            lb4.Text = "Simple TextBox";
            lb4.Draw(2, 14, ConsoleColor.Yellow, ConsoleColor.Blue);

            TextBox tx = new TextBox();
            tx.Draw(18, 14);


            //CheckBox Example
            CheckBox ck = new CheckBox();
            ck.Text = "CheckBox";
            ck.Checked = true;
            ck.Draw(2, 18);

            CheckBox ck2 = new CheckBox();
            ck2.Text = "Uncheked";
            ck2.Checked = false;
            ck2.Draw(20, 18);

            //---------------


            //Panel
            Panel pp = new Panel();
            pp.Width = 65;
            pp.Draw(2, 22);

            Label lb6 = new Label();
            lb6.Text = "Simple Panel";
            lb6.Draw(8, 23, ConsoleColor.Black, ConsoleColor.Gray);


            //Status Bar
            StatusBar st = new StatusBar();
            st.StatusText = "Ready...";
            st.Draw(w, h);


            
            //Button Example
            Button bt = new Button();
            bt.Text = "OK";
            bt.Selected = true;
           

            Button bt2 = new Button();
            bt2.Text = "Next Example";
            bt2.Selected = false;

            Label lbl = new Label();
            lbl.Text = "Press tab for switch button";
            lbl.Draw(5, 27,ConsoleColor.Red, ConsoleColor.Gray);
            //---------------

                      



              //Render Cicle
        start:


            //Button Drawing
            bt.Draw(5, 30);
            bt2.Draw(12, 30);

            k = Console.ReadKey();

            
            //ProgressBar Render Cicle
        if (k.Key == ConsoleKey.Enter)
        {
            p.Value++;
            p.Draw(2, 12);

            if (bt2.Selected) { Screen2 sc = new Screen2(); goto end; } //Call Next Screen

        } else

        if (k.Key == ConsoleKey.Tab)
        {
            if (bt.Selected)
            {
                bt.Selected = false;
                bt2.Selected = true;
            }
            else
            {
                bt.Selected = true;
                bt2.Selected = false;
            }
        }
        else
        {
            Console.SetCursorPosition(0, 0);


        }
        
            //------------



       goto start;



         end:

       string t = "emtpy";
         Screen2 scs = new Screen2();
         scs.main();
        }
    }
}
